home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / BGUI11c.lha / demos / vector.c < prev    next >
C/C++ Source or Header  |  1994-10-05  |  6KB  |  200 lines

  1. /*
  2. **         $RCSfile: Vector.c,v $
  3. **      Description: Simple demonstration of the vector class
  4. **        Copyright: (C) Copyright 1994 Paul Weterings
  5. **                   All Rights Reserved.
  6. **
  7. **          $Author: Paul $
  8. **        $Revision: 1.1 $
  9. **            $Date: 1994/09/10 11:23:13 $
  10. **/
  11.  
  12. #include <libraries/bgui.h>
  13. #include <libraries/bgui_macros.h>
  14. #include <libraries/gadtools.h>
  15. #include <clib/alib_protos.h>
  16. #include <clib/exec_protos.h>
  17. #include <clib/bgui_protos.h>
  18. #include <clib/intuition_protos.h>
  19.  
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22.  
  23. /*
  24. **      Library base pointer.
  25. **      NOTE: The intuition.library is opened by SAS or DICE's
  26. **      auto-init code.
  27. **/
  28. struct Library                  *BGUIBase;
  29.  
  30. /*
  31. **      Object ID's. Please note that the ID's are shared
  32. **      between the menus and the gadget objects.
  33. **/
  34. #define ID_QUIT                 1
  35. #define CLOCK_WIDTH            21
  36.  
  37. /*
  38. **      Simple menu strip.
  39. **/
  40. struct NewMenu SimpleMenu[] = {
  41.         NM_TITLE,       "Project",      NULL,   0,      0,      NULL,
  42.         NM_ITEM,        "Quit",         "Q",    0,      0,      ( APTR )ID_QUIT,
  43.         NM_END,         NULL,           NULL,   0,      0,      NULL
  44. }
  45. ;
  46.  
  47. int main( int argc, char *argv[] )
  48. {
  49.         struct Window           *window;
  50.         Object                  *WO_Window, *GO_Quit, *GO_Vec;
  51.         ULONG                    signal = 0, rc, tmp = 0;
  52.         BOOL                     running = TRUE;
  53.  
  54.    /*
  55.    ** The vector structure, filled with the data to draw the clock
  56.    **
  57.    ** TIP: If you are going to design your own vector imagery, make sure
  58.    ** to keep the x-y coordinate values as small as possible: i.e. design the
  59.    ** vector image as small as possible.
  60.    */
  61.    struct VectorItem clockvec[] =
  62.    {
  63.    16, 16, VIF_SCALE,
  64.     0,  0, VIF_SHINEPEN,
  65.     SHADOWPEN,  0, VIF_AOLDRIPEN,   /* set the outline to shadowcolor */
  66.     0,  0, VIF_AREASTART,           /* draw the inner cicle, and fill */
  67.     8,  2, VIF_MOVE,
  68.    12,  4, VIF_DRAW,
  69.    14,  8, VIF_DRAW,
  70.    12, 12, VIF_DRAW,
  71.     8, 14, VIF_DRAW,
  72.     4, 12, VIF_DRAW,
  73.     2,  8, VIF_DRAW,
  74.     4,  4, VIF_DRAW,
  75.     8,  2, VIF_DRAW,
  76.     0,  0, VIF_AREAEND,
  77.     0,  0, VIF_ENDOPEN,
  78.  
  79.     0,  0, VIF_SHADOWPEN,
  80.     8,  4, VIF_MOVE,                /* draw the pips */
  81.     8,  4, VIF_MOVE,
  82.    12,  8, VIF_MOVE,
  83.    12,  8, VIF_DRAW,
  84.     8, 12, VIF_MOVE,
  85.     8, 12, VIF_DRAW,
  86.     4,  8, VIF_MOVE,
  87.     4,  8, VIF_DRAW,
  88.     8,  4, VIF_MOVE,
  89.     8,  4, VIF_DRAW,
  90.  
  91.     11,  5, VIF_MOVE,               /* draw the arrows */
  92.      8,  8, VIF_DRAW,
  93.     10, 10, VIF_DRAW,
  94.  
  95.    0 ,  0, VIF_LASTITEM
  96.    };
  97.  
  98.         /*
  99.    **      Open the library.
  100.    **/
  101.         if ( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION )) {
  102.                 /*
  103.       **      Create the window object.
  104.       **/
  105.                 WO_Window = WindowObject,
  106.                 WINDOW_Title,           "Vectorclass Demo",
  107.                 WINDOW_MenuStrip,       SimpleMenu,
  108.                 WINDOW_SizeGadget,      TRUE,
  109.                 WINDOW_MasterGroup,
  110.                 HGroupObject,
  111.                 StartMember,
  112.             GO_Vec = ButtonObject,
  113.             VIT_VectorArray, clockvec,
  114.             ButtonFrame,
  115.          EndObject, FixWidth(CLOCK_WIDTH), EndMember,
  116.                 VarSpace( 50 ),
  117.                 StartMember, GO_Quit  = KeyButton( "_Quit",  ID_QUIT  ), EndMember,
  118.                 EndObject,
  119.                 EndObject;
  120.  
  121.                 /*
  122.       **      Object created OK?
  123.       **/
  124.                 if ( WO_Window ) {
  125.                         /*
  126.          **      Assign a key to the button.
  127.          **/
  128.                         tmp += GadgetKey( WO_Window, GO_Quit,  "q" );
  129.                         /*
  130.          **      OK?
  131.          **/
  132.                         if ( tmp == 1 ) {
  133.                                 /*
  134.             **      try to open the window.
  135.             **/
  136.                                 if ( window = WindowOpen( WO_Window )) {
  137.                                         /*
  138.                **      Obtain it's wait mask.
  139.                **/
  140.                                         GetAttr( WINDOW_SigMask, WO_Window, &signal );
  141.                                         /*
  142.                **      Event loop...
  143.                **/
  144.                                         do {
  145.                                                 Wait( signal );
  146.                                                 /*
  147.                   **      Handle events.
  148.                   **/
  149.                                                 while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
  150.                                                         /*
  151.                      **      Evaluate return code.
  152.                      **/
  153.                                                         switch ( rc ) {
  154.  
  155.                                                                 case    WMHI_CLOSEWINDOW:
  156.                                                                 case    ID_QUIT: /* there's no break here */
  157.                                                                 running = FALSE; /* so false is set */
  158.                                                                 break;
  159.                                                         }
  160.                                                 }
  161.                                         }
  162.                                         while ( running );
  163.                                 }
  164.                                 else
  165.                                 puts ( "Could not open the window" );
  166.                         }
  167.                         else
  168.                         puts( "Could not assign gadget keys" );
  169.                         /*
  170.          **      Disposing of the window object will
  171.          **      also close the window if it is
  172.          **      already opened and it will dispose of
  173.          **      all objects attached to it.
  174.          **/
  175.                         DisposeObject( WO_Window );
  176.                 }
  177.                 else
  178.                 puts( "Could not create the window object" );
  179.                 CloseLibrary( BGUIBase );
  180.         }
  181.         else
  182.         puts( "Unable to open the bgui.library" );
  183.  
  184.         return( 0 );
  185. }
  186.  
  187. #ifdef _DCC
  188. int wbmain( struct WBStartup *wbs )
  189. {
  190.         return( main( 0, NULL ));
  191. }
  192. #endif
  193.  
  194. /*
  195.  *      $Log: Vector.c,v $
  196.  * Revision 1.1  1994/09/10  11:23:13  Paul
  197.  * Initial revision
  198.  *
  199.  */
  200.